package com.egao.common.module.system.controller;

import com.egao.common.core.web.JsonResult;
import com.egao.common.module.student.entity.StudentSignSet;
import com.egao.common.module.student.service.StudentSignSetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 自定义签约信息
 * @author pyx
 */
@Api(tags = "自定义签约信息")
@RestController
@RequestMapping("${api}")
public class StudentSignSetController {
    @Autowired
    private StudentSignSetService studentSignSetService;

    @PreAuthorize("hasAuthority('student:set:detail')")
    @ApiOperation("查询全部信息")
    @GetMapping("/student/sign/set")
    public JsonResult get(){
        StudentSignSet studentSignSet = studentSignSetService.get();
        if(studentSignSet == null){
            return JsonResult.error("暂无数据");
        }
        return JsonResult.ok().setData(studentSignSet);
    }

    @PreAuthorize("hasAuthority('student:set:insert')")
    @ApiOperation("添加信息")
    @PostMapping("/student/sign/set")
    public JsonResult save(@RequestBody StudentSignSet studentSignSet){
        return studentSignSetService.saveSet(studentSignSet);
    }
}
